package com.itjiange.publisher;

import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * @author ItJiange
 * @date 2023-10-03
 */
@SpringBootTest
public class SpringAmqp {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Test
    public void amqpTest() {
        rabbitTemplate.convertAndSend("simple.queue", "健哥好帅");
    }

    @Test
    public void amqpTest01() throws InterruptedException {
        String queueName = "simple.queue";
        rabbitTemplate.convertAndSend(queueName, "健哥哥该休息了");
    }

    @Test
    public void amqpWorkTest() throws InterruptedException {
        String queueName = "work.queue";
        for (int i = 0; i < 50; i++) {
            rabbitTemplate.convertAndSend(queueName, "健哥哥该休息了" + (i + 1));
            Thread.sleep(20);
        }
    }
}
